-
Notifications
You must be signed in to change notification settings - Fork 617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
grpc-js: Add a timer that holds the event loop open while there are pending calls #1580
grpc-js: Add a timer that holds the event loop open while there are pending calls #1580
Conversation
packages/grpc-js/src/channel.ts
Outdated
@@ -230,6 +239,14 @@ export class ChannelImplementation implements Channel { | |||
new MaxMessageSizeFilterFactory(this.options), | |||
new CompressionFilterFactory(this), | |||
]); | |||
|
|||
this.callRefTimer = setInterval(() => {}, 1 << 31 - 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't there a maxint constant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is Number.MAX_SAFE_INTEGER
, but it's larger than that, and Number.MAX_VALUE
, which is even larger.
packages/grpc-js/src/channel.ts
Outdated
@@ -230,6 +239,14 @@ export class ChannelImplementation implements Channel { | |||
new MaxMessageSizeFilterFactory(this.options), | |||
new CompressionFilterFactory(this), | |||
]); | |||
|
|||
this.callRefTimer = setInterval(() => {}, 1 << 31 - 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, https://www.npmjs.com/package/node-noop :-P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly, that's not even the only package that provides a noop function. We used to depend on one of them.
This should fix #1579.
We want to hold the event loop open as long as there is an active call. For most of the lifetime of most calls, this is accomplished by
ref
ing each subchannel as long as it is handling at least one active call. However, that does not account for calls that are never attached to subchannels. This closes that gap by creating an interval timer that lasts for the lifetime of the channel. Weref
that timer as long as there is at least one pending call on the channel that has not been assigned to a subchannel.